/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.teamreinforce.ejb.entities;

import java.io.Serializable;
import java.util.List;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author tidiane
 */
@Entity
@Table(name = "tache")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Tache.findAll", query = "SELECT t FROM Tache t"),
    @NamedQuery(name = "Tache.findByIdTache", query = "SELECT t FROM Tache t WHERE t.idTache = :idTache"),
    @NamedQuery(name = "Tache.findByLibelle", query = "SELECT t FROM Tache t WHERE t.libelle = :libelle"),
    @NamedQuery(name = "Tache.findByDateDebut", query = "SELECT t FROM Tache t WHERE t.dateDebut = :dateDebut"),
    @NamedQuery(name = "Tache.findByDateFin", query = "SELECT t FROM Tache t WHERE t.dateFin = :dateFin"),
    @NamedQuery(name = "Tache.findByDuree", query = "SELECT t FROM Tache t WHERE t.duree = :duree"),
    @NamedQuery(name = "Tache.findByAvancement", query = "SELECT t FROM Tache t WHERE t.avancement = :avancement")})
public class Tache implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @NotNull
    @Column(name = "id_tache")
    private Integer idTache;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 100)
    @Column(name = "libelle")
    private String libelle;
    @Lob
    @Size(max = 65535)
    @Column(name = "description")
    private String description;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "date_debut")
    private String dateDebut;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "date_fin")
    private String dateFin;
    @Column(name = "duree")
    private Integer duree;
    @Basic(optional = false)
    @NotNull
    @Column(name = "avancement")
    private int avancement;
    @ManyToMany(mappedBy = "tacheList", fetch= FetchType.EAGER)
    private List<Collaborateur> collaborateurList;
    @JoinColumn(name = "etape", referencedColumnName = "id_etape")
    @ManyToOne(optional = false)
    private Etape etape;
    @OneToMany(mappedBy = "tacheParente", fetch= FetchType.EAGER)
    private List<Tache> tacheList;
    @JoinColumn(name = "tache_parente", referencedColumnName = "id_tache")
    @ManyToOne (fetch= FetchType.EAGER)
    private Tache tacheParente;

    public Tache() {
    }

    public Tache(Integer idTache) {
        this.idTache = idTache;
    }

    public Tache(Integer idTache, String libelle, String dateDebut, String dateFin, int avancement) {
        this.idTache = idTache;
        this.libelle = libelle;
        this.dateDebut = dateDebut;
        this.dateFin = dateFin;
        this.avancement = avancement;
    }

    public Integer getIdTache() {
        return idTache;
    }

    public void setIdTache(Integer idTache) {
        this.idTache = idTache;
    }

    public String getLibelle() {
        return libelle;
    }

    public void setLibelle(String libelle) {
        this.libelle = libelle;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getDateDebut() {
        return dateDebut;
    }

    public void setDateDebut(String dateDebut) {
        this.dateDebut = dateDebut;
    }

    public String getDateFin() {
        return dateFin;
    }

    public void setDateFin(String dateFin) {
        this.dateFin = dateFin;
    }

    public Integer getDuree() {
        return duree;
    }

    public void setDuree(Integer duree) {
        this.duree = duree;
    }

    public int getAvancement() {
        return avancement;
    }

    public void setAvancement(int avancement) {
        this.avancement = avancement;
    }

    @XmlTransient
    public List<Collaborateur> getCollaborateurList() {
        return collaborateurList;
    }

    public void setCollaborateurList(List<Collaborateur> collaborateurList) {
        this.collaborateurList = collaborateurList;
    }

    public Etape getEtape() {
        return etape;
    }

    public void setEtape(Etape etape) {
        this.etape = etape;
    }

    @XmlTransient
    public List<Tache> getTacheList() {
        return tacheList;
    }

    public void setTacheList(List<Tache> tacheList) {
        this.tacheList = tacheList;
    }

    public Tache getTacheParente() {
        return tacheParente;
    }

    public void setTacheParente(Tache tacheParente) {
        this.tacheParente = tacheParente;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idTache != null ? idTache.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Tache)) {
            return false;
        }
        Tache other = (Tache) object;
        if ((this.idTache == null && other.idTache != null) || (this.idTache != null && !this.idTache.equals(other.idTache))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.teamreinforce.ejb.entities.Tache[ idTache=" + idTache + " ]";
    }
    
}
